import java.util.InputMismatchException;
import java.util.Scanner;

public class Test1 {

    public static int getElement(int[] array, int index){
        if(array == null){
            //throw new NullPointerException("传递的数组为null");
        }

        if(index < 0 || index >= array.length){
            throw new ArithmeticException("数组的下标越界了...");
        }

        return array[index];
    }

    public static void main(String[] args) {
        int[] array = {1,2,3};
        // getElement(array, 6);

        Scanner sc = new Scanner(System.in);
        try {
            int ret = sc.nextInt();
        }catch (InputMismatchException e){
            e.printStackTrace();
            System.out.println("输入数据不匹配");
        }finally {
            System.out.println("执行finally部分,一般用来关闭资源");
            sc.close();
        }

    }

    public static void main3(String[] args) {
        int a = 10;
        int[] array = null;
        try {
            System.out.println(array.length);
            System.out.println(a/10);
        } catch (NullPointerException e){
            e.printStackTrace();
            System.out.println("出现了空指针异常");
        }catch (ArithmeticException e){
            e.printStackTrace();
            System.out.println("出现了算术异常");
        }catch (Exception e){
            e.printStackTrace();
            System.out.println("出现了异常...");
        }

        System.out.println("执行后续代码");
    }

    public static void main2(String[] args) {
        int a = 10;
        try {
            System.out.println(a/0);
        }catch (ArithmeticException e){
            e.printStackTrace();
            System.out.println("出现了算术异常");
        }
        System.out.println("执行后续代码");
    }

    public static void main1(String[] args) {
        /*int a = 10;
        System.out.println(a/0);
        System.out.println("执行后续代码");*/

        /*int[] array = {1,2,3,4,5};
        System.out.println(array[20]);*/

        /*int[] array = null;
        System.out.println(array.length);*/

    }
}
